package com.qj.yantaishan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.IService;
import com.qj.yantaishan.domain.Comment;
import org.apache.ibatis.annotations.Select;

/**
 * 评论Mapper接口
 *
 * @author qihe
 * @date 2022-07-22
 */
public interface CommentMapper extends BaseMapper<Comment> {
    /**
     * 查询评论
     *
     * @param id 评论主键
     * @return 评论
     */
    public Comment selectCommentById(Long id);

    /**
     * 查询评论列表
     *
     * @param comment 评论
     * @return 评论集合
     */
    public List<Comment> selectCommentList(Comment comment);

    /**
     * 新增评论
     *
     * @param comment 评论
     * @return 结果
     */
    public int insertComment(Comment comment);

    /**
     * 修改评论
     *
     * @param comment 评论
     * @return 结果
     */
    public int updateComment(Comment comment);

    /**
     * 删除评论
     *
     * @param id 评论主键
     * @return 结果
     */
    public int deleteCommentById(Long id);

    /**
     * 批量删除评论
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCommentByIds(String[] ids);

    @Select("select count(*) from shanglala_comment  where delete_flg =0 and content != ''")
    int total();

    @Select("select sc.id,sp.product_id,sp.name product_name,sp.product_id,su.nickname,su.avatar, sp.image product_image,sc.content,ifnull(sca.file,'') comment_image,sc.dateline,sc.score,sc.status from shanglala_comment sc inner join shanglala_user su  on sc.uid = su.uid left join shanglala_product sp on sc.relation_id   = sp.product_id  left join shanglala_comment_attachment sca on sc.id = sca.cid  where sc.delete_flg =0 and sc.content != ''\n" +
            " ")
    List<Comment> mySelectCommentList();
}
